package cn.le.netty.config;

import cn.le.netty.inf.NettyHandler;
import cn.le.netty.util.NettyFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class HandlerConfig {

    @Autowired
    private ApplicationContext applicationContext;

    @Bean
    public void handlers(){
        List<NettyHandler> list = new ArrayList<>(applicationContext.getBeansOfType(NettyHandler.class).values());
        NettyFactory.setNettyHandlers(list);
    }
}
